package com.appspot.seqpop.model;

import java.io.Serializable;

import com.google.appengine.api.datastore.Key;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

@Model(schemaVersion = 1)
public class Sequence implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final Object GAP = '-';
    
    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;
    
    private String description;
    
    @Attribute(lob = true)
    private String sequence;
    
    public Sequence() {
    }
    
    public Sequence(String description, String sequence) {
        setDescription(description);
        setSequence(sequence);
    }

    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getSequence() {
        return this.sequence;
    }
    
    public void setSequence(String sequence) {
        this.sequence = sequence;
    }

    public int getLength() {
        return this.sequence.length();
    }
    
    public Object getElementAt(int index) {
        return this.sequence.charAt(index);
    }

//    @Override
//    public int hashCode() {
//        final int prime = 31;
//        int result = 1;
//        result = prime * result + ((key == null) ? 0 : key.hashCode());
//        return result;
//    }
//
//    @Override
//    public boolean equals(Object obj) {
//        if (this == obj) {
//            return true;
//        }
//        if (obj == null) {
//            return false;
//        }
//        if (getClass() != obj.getClass()) {
//            return false;
//        }
//        Sequence other = (Sequence) obj;
//        if (key == null) {
//            if (other.key != null) {
//                return false;
//            }
//        } else if (!key.equals(other.key)) {
//            return false;
//        }
//        return true;
//    }
}
